package com.mspbots.core.ticketai;


import com.mspbots.core.AbstractBaseController;
import com.mspbots.core.ticketai.model.RuleStatusPoints;
import com.mspbots.core.ticketai.service.RuleStatusPointsService;
import lombok.RequiredArgsConstructor;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.Callable;

@RestController
@RequiredArgsConstructor
@RequestMapping("rule/status-points")
public class RuleStatusPointsController extends AbstractBaseController<RuleStatusPoints, RuleStatusPointsService> {

    @PostMapping(path = "save")
    public Callable save(@RequestBody List<RuleStatusPoints> statusPointsList) {
        Assert.notEmpty(statusPointsList, "Parameters cannot be empty!");
        return () -> this.service.saveBatchAll(statusPointsList);
    }

    @GetMapping(path = "/data")
    public Callable selectData(Long tenantId) {
        Assert.notNull(tenantId, "Parameter [tenantId] cannot be empty!");
        return () -> this.service.selectData(tenantId);
    }

    @GetMapping(path = "/init")
    public Callable initData(Long tenantId) {
        Assert.notNull(tenantId, "Parameter [tenantId] cannot be empty!");
        return () -> this.service.initData(tenantId);
    }

    @GetMapping(path = "/preview")
    public Callable previewData(Long tenantId) {
        Assert.notNull(tenantId, "Parameter [tenantId] cannot be empty!");
        return () -> this.service.getAllStatusPoints(tenantId);
    }

}
